<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <!-- BEGIN GLOBAL MANDATORY STYLES -->

    <!-- BEGIN GLOBAL MANDATORY STYLES -->
    <#include "../inc/list.ftl"/>
    <@list/>
</head>
<body >
<div class="panel panel-default">
    <div class="panel-body">
        <div class="row">
            <div class="col-lg-12">
                <form id="form" >
                    <div class="form-group">
                        <label>服装</label>
                        <select id="clothing"  name="clothing"  class="form-control" >
                        </select>
                    </div>

                    <div class="form-group">
                        <label>数量</label>
                        <input id="number"  name="number" class="form-control">
                    </div>

                    <div align="right">
                        <button id="btn-submit"  type="button"  class="btn btn-default" >提交</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <!-- /.panel-body -->
</div>
<!-- /.panel -->
<script>
    $(document).ready(function() {

        $("#btn-submit").click(function(){
            var clothing = $.trim($("#clothing").val());
            var number = $.trim($("#number").val());
            if(number==""){
                layer.msg('有信息未输入，请检查!', {time: 2000});
            }else {
                var data1= {};
                data1.orderId = ${(orderId)!};
                data1.number = number;
                data1.clothingId = clothing;
                $.ajax({
                    type:"POST",
                    url:"/order/saveDetail",  //接口
                    data:JSON.stringify(data1),
                    contentType: "application/json",
                    success:function(data){
                        if(data.result){
                            parent.layer.msg(data.msg, {time: 1000, icon:1});
                        }else{
                            parent.layer.msg(data.msg, {time: 1000, icon:2});
                        }
                        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                        parent.layer.close(index);
                    }
                });
            }
        });
        initSelector1();

    });
    function initSelector1(){
        var selector1=  $("#clothing");
        //freemarker遍历用法
        selector1.append("<option value='-1'>选择服装</option>");
            <#list clothing as t>
                var name="${t.clothingname}";
                var id = "${t.id}";
                selector1.append("<option value='"+id+"'>"+name+"</option>");
            </#list>

    }
</script>
</body>

</html>